package day11;

import java.util.Scanner;

public class demo2 {    public static void main(String[] args) {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    int[]dp1=new int[n];
    int[]dp2=new int[n];
    int []arr=new int[n];
    for (int i = 0; i <n ; i++) {
        arr[i]= in.nextInt();
    }
    dp1[0]=-arr[0];
    for (int i = 1; i <n ; i++) {
        dp1[i]=Math.max(dp2[i-1]-arr[i],dp1[i-1]);
        dp2[i]=Math.max(dp1[i-1]+arr[i],dp2[i-1]);
    }
    System.out.println(dp2[n-1]);


}
}
